/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package membershipdemo;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author labib.farag
 */
@Entity
@Table(name = "subvention", catalog = "membership_affairs", schema = "")
@NamedQueries({
    @NamedQuery(name = "Subvention.findAll", query = "SELECT s FROM Subvention s"),
    @NamedQuery(name = "Subvention.findById", query = "SELECT s FROM Subvention s WHERE s.id = :id"),
    @NamedQuery(name = "Subvention.findByServiceType", query = "SELECT s FROM Subvention s WHERE s.serviceType = :serviceType"),
    @NamedQuery(name = "Subvention.findByRequestDate", query = "SELECT s FROM Subvention s WHERE s.requestDate = :requestDate"),
    @NamedQuery(name = "Subvention.findByIncomingNumber", query = "SELECT s FROM Subvention s WHERE s.incomingNumber = :incomingNumber"),
    @NamedQuery(name = "Subvention.findByAmount", query = "SELECT s FROM Subvention s WHERE s.amount = :amount"),
    @NamedQuery(name = "Subvention.findByReceiveDate", query = "SELECT s FROM Subvention s WHERE s.receiveDate = :receiveDate"),
    @NamedQuery(name = "Subvention.findByNotes", query = "SELECT s FROM Subvention s WHERE s.notes = :notes")})
public class Subvention implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "service_type")
    private String serviceType;
    @Basic(optional = false)
    @Column(name = "request_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date requestDate;
    @Basic(optional = false)
    @Column(name = "incoming_number")
    private int incomingNumber;
    @Basic(optional = false)
    @Column(name = "amount")
    private int amount;
    @Basic(optional = false)
    @Column(name = "receive_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date receiveDate;
    @Basic(optional = false)
    @Column(name = "notes")
    private String notes;
    @JoinColumn(name = "mem_id", referencedColumnName = "mem_id")
    @ManyToOne(optional = false)
    private Members memId;

    public Subvention() {
    }

    public Subvention(Integer id) {
        this.id = id;
    }

    public Subvention(Integer id, String serviceType, Date requestDate, int incomingNumber, int amount, Date receiveDate, String notes) {
        this.id = id;
        this.serviceType = serviceType;
        this.requestDate = requestDate;
        this.incomingNumber = incomingNumber;
        this.amount = amount;
        this.receiveDate = receiveDate;
        this.notes = notes;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public String getServiceType() {
        return serviceType;
    }

    public void setServiceType(String serviceType) {
        String oldServiceType = this.serviceType;
        this.serviceType = serviceType;
        changeSupport.firePropertyChange("serviceType", oldServiceType, serviceType);
    }

    public Date getRequestDate() {
        return requestDate;
    }

    public void setRequestDate(Date requestDate) {
        Date oldRequestDate = this.requestDate;
        this.requestDate = requestDate;
        changeSupport.firePropertyChange("requestDate", oldRequestDate, requestDate);
    }

    public int getIncomingNumber() {
        return incomingNumber;
    }

    public void setIncomingNumber(int incomingNumber) {
        int oldIncomingNumber = this.incomingNumber;
        this.incomingNumber = incomingNumber;
        changeSupport.firePropertyChange("incomingNumber", oldIncomingNumber, incomingNumber);
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        int oldAmount = this.amount;
        this.amount = amount;
        changeSupport.firePropertyChange("amount", oldAmount, amount);
    }

    public Date getReceiveDate() {
        return receiveDate;
    }

    public void setReceiveDate(Date receiveDate) {
        Date oldReceiveDate = this.receiveDate;
        this.receiveDate = receiveDate;
        changeSupport.firePropertyChange("receiveDate", oldReceiveDate, receiveDate);
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        String oldNotes = this.notes;
        this.notes = notes;
        changeSupport.firePropertyChange("notes", oldNotes, notes);
    }

    public Members getMemId() {
        return memId;
    }

    public void setMemId(Members memId) {
        Members oldMemId = this.memId;
        this.memId = memId;
        changeSupport.firePropertyChange("memId", oldMemId, memId);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subvention)) {
            return false;
        }
        Subvention other = (Subvention) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "membershipdemo.Subvention[ id=" + id + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
